package cn.micai.base.io;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 描述：反序列化
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/7 12:13
 */
public class DeserializeMain {

    public static void main(String [] args) {
        Employee emp = null;
        try {
            FileInputStream inputStream = new FileInputStream("D://employee.ser");
            ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
            emp = (Employee) objectInputStream.readObject();
            objectInputStream.close();
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } catch (ClassNotFoundException e) {
            System.out.println("Employee class not found");
            e.printStackTrace();
            return;
        }
        System.out.println("Deserialized Employee...");
        System.out.println("Emp id: " + emp.getEmployeeId());
        System.out.println("Name: " + emp.getEmployeeName());
        System.out.println("Department: " + emp.getDepartment());
    }
}
